package top.guxx.mall;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author：Guxx
 * @Description：
 * @Date：2025/2/23 2:46
 * @Filename：StringUtils
 */
public class StringUtils {
    public static String list2StringByDelimiter(List<String> list, String delimiter){
        StringBuilder sb = new StringBuilder(list.get(0));
        for (String str : list){
            if (str.equals(list.get(0))) continue;
            sb.append(delimiter).append(str);
        }
        return sb.toString();
    }

    public static List<String> str2ListByDelimiter(String str, String delimiter){
        String[] split = str.split(delimiter);
        ArrayList<String> res = new ArrayList<>();
        for (String ele : split) {
            res.add(ele);
        }
        return res;
    }
}
